﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using ExamDemo.Models;

namespace ExamDemo.Data
{
    public class Datalnitlizer:DropCreateDatabaseIfModelChanges<ExamDemoContext>
    {
        protected override void Seed(ExamDemoContext db)
        {
            //用户
            db.Users.AddRange(new List<Users>
            {
                new Users
                {
                    Username="百岁山",
                    Password="123"
                },new Users
                {
                    Username="农夫山泉",
                    Password="123"
                },new Users
                {
                    Username="怡宝",
                    Password="123"
                },new Users
                {
                    Username="依泉",
                    Password="123"
                },
            });

            //发布的说说
            db.Messages.AddRange(new List<Messages>
            {
                new Messages
                {
                    FromUserId=1,
                    Content="水中贵族百岁山"
                },new Messages
                {
                    FromUserId=2,
                    Content="我们不生产水，我们只是大自然的搬运工"
                },new Messages
                {
                    FromUserId=3,
                    Content="用韩语念我更甜哦"
                },new Messages
                {
                    FromUserId=4,
                    Content="就这？"
                }
            });

            //评论
            db.Comments.AddRange(new List<Comments>
            {
                new Comments
                {
                    FromUserId=1,
                    ToUserId=4,
                    Comment="会这样？"
                },new Comments
                {
                    FromUserId=3,
                    ToUserId=2,
                    Comment="大哥好棒"
                },new Comments
                {
                    FromUserId=2,
                    ToUserId=4,
                    Comment="厉害"
                },new Comments
                {
                    FromUserId=1,
                    ToUserId=2,
                    Comment="哈哈"
                },
            });

            db.SaveChanges();

            base.Seed(db);
        }
    }
}
